<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto" lay-filter="LAY-list-form">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">货币名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">发布日期</label>
                    <div class="layui-input-block layui-jy-datetime">
                        <input type="text" name="date" id="date" placeholder="" autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <button style="display:none" class="down" lay-submit="" lay-filter="LAY-list-down">下载</button>
                    <button class="layui-btn layuiadmin-btn-useradmin search" lay-submit lay-filter="LAY-list-search">搜索</button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <table id="LAY-list"  lay-filter="LAY-list"></table>
            <!-- 行内工具 -->
            <script type="text/html" id="LAY-list-toolbar">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-href="user/edit/id={{d.id}}">编辑</a>
                {{# if(d.status==1){ }}
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="enable">禁用</a>
                {{# }else{ }}
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="disable">启用</a>
                {{# } }}
            </script>
            <!-- 头部工具栏 -->
            <script type="text/html" id="toolbar">
                <div class="layui-btn-group fl layui-btn-group-jy">
                    <a lay-event="export" href="javascript:;" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-download-circle">&nbsp;导出</a>
                    <a lay-event="update" href="javascript:;" class="layui-btn layui-btn-primary layui-btn-sm layui-icon layui-icon-refresh">&nbsp;更新</a>
                </div>
            </script>


        </div>
    </div>
</div>

<script>
    layui.use(['admin', 'table', 'form','toolJ','laydate'], function () {
        var $ = layui.$
            , admin = layui.admin
            , view = layui.view
            , table = layui.table
            , toolJ = layui.toolJ
            , laydate = layui.laydate
            , form = layui.form;
        //日期时间范围
        laydate.render({
            elem: '#date'
            ,type: 'datetime'
            ,range: true
        });
        //用户管理
        table.render({
            elem: '#LAY-list'
            ,url: '/index/exchange/getList'
            ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter']
            ,cols: [[
                {field: 'name', title: '货币名称'}
                ,{field: 'fBuyPri', title: '现汇买入价'}
                ,{field: 'mBuyPri', title: '现钞买入价'}
                ,{field: 'fSellPri', title: '现汇卖出价'}
                ,{field: 'mSellPri', title: '现钞卖出价'}
                ,{field: 'bankConversionPri', title: '中行折算价'}
                ,{field: 'date', title: '发布日期'}
            ]]
            ,page: true
            ,limit: 10
            ,text:{none: '暂无相关数据!' }
        });
        //监听头部工具栏 操作
        table.on('toolbar(LAY-list)', function (obj) {
            //选中的数据
            var checkStatus = table.checkStatus('LAY-list')
                , data = checkStatus.data;
            //event对应模板的
            switch (obj.event) {
                case 'export':
                    $('.down').click();
                    break;
                case 'update':
                    toolJ.ajax({"url":"/index/exchange/getExchangeByApi"});
                    break;
            }
        })

    });
</script>